<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page import="org.tools.wstt.reference.ApplicationComponent"%>

<c:set var="title" scope="request">Fetch HTTP URL</c:set>

<jsp:include page="/WEB-INF/jsp/inc/head.jsp" />

		<h2>Configure an HTTP request</h2>
		<form method="POST" action="<c:out value="${servicesPath}" /><%=ApplicationComponent.URI_FETCH_URL %>">
			<p>
				<label for="url">URL : </label><input id="url" type="text" size="100" name="url" /><br />
				<label for="method">Method : </label>
				<select id="method" name="method">
					<option value="GET">GET</option>
					<option value="POST">POST</option>
					<option value="PUT">PUT</option>
					<option value="DELETE">DELETE</option>
					<option value="HEAD">HEAD</option>
					<option value="OPTIONS">OPTIONS</option>
					<option value="TRACE">TRACE</option>
				</select>
				<br />
				<label for="timeout">Timeout in ms : </label><input id="timeout" type="text" name="timeout" value="5000" /><br />
				<label for="httpHeaders">HTTP Headers : </label><textarea cols="70" rows="5" id="httpHeaders" type="text" name="httpHeaders"></textarea><br />
				<label for="httpContent">HTTP Content : </label><textarea cols="70" rows="10" id="httpContent" type="text" name="httpContent"></textarea><br />
				<input id="useProxy" type="checkbox" name="useProxy" /><label for="useProxy">Use a proxy Server</label><br />
				<label for="proxyHost">Proxy Host : </label><input id="proxyHost" type="text" name="proxyHost" /><br />
				<label for="proxyPort">Proxy Port : </label><input id="proxyPort" type="text" name="proxyPort" maxlength="5" /><br />
				<input type="submit" value="Send It" />
			</p>
		</form>
		
		<h2>HTTP fetch Results History</h2>
		<div id="request_results">
			<p><em>only the last <%=ApplicationComponent.APP_REQUEST_REMIND_CALLS %> sent requests are viewable.</em></p>
			<table>
				<tbody>
					<tr>
						<th>Destination URL</th>
						<th>Response Status Code</th>
						<th>Method</th>
						<th>Date</th>
						<th>Time elapsed (ms)</th>
						<th>Request Headers</th>
						<th>Request Content</th>
						<th>Response Headers</th>
						<th>Response Content</th>
					</tr>
					<c:forEach var="call" items="${applicationScope['REQUEST_CALLS']}">
						<tr>
							<td><c:out value="${call.url}" /></td>
							<td><c:out value="${call.status}" /></td>
							<td><c:out value="${call.method}" /></td>
							<td><fmt:formatDate pattern="dd/MM/yyyy HH:mm:SS" value="${call.date}" timeZone="GTM+1" /></td>
							<td><c:out value="${call.time}" /></td>
							<td><c:out value="${call.inputHeaders}" /></td>
							<td><c:out value="${call.inputContent}" /></td>
							<td><c:out value="${call.outputHeaders}" /></td>
							<td><c:out value="${call.outputContent}" /></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>

<jsp:include page="/WEB-INF/jsp/inc/foot.jsp" />